package com.yc.ssm.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.ssm.bean.TypeInfo;
import com.yc.ssm.biz.ITypeInfoBiz;
import com.yc.ssm.mapper.ITypeInfoMapper;
import com.yc.ssm.util.StringUtil;
@Service
public class TypeInfoBizImpl implements ITypeInfoBiz {
	@Autowired
	private ITypeInfoMapper typeInfoMapper;
	@Override
	public int add(TypeInfo tf) {
		if(StringUtil.checkNull(tf.getTname())) {
			return -1;
		}
		return typeInfoMapper.add(tf);
	}

	@Override
	public List<TypeInfo> finds() {
		return typeInfoMapper.finds();
	}

	@Override
	public Map<String, Object> findByPage(Map<String,Object> map) {
		//System.out.println(map);
		List<TypeInfo> list = typeInfoMapper.findByPage(StringUtil.findByPageUtil2(map));
		//System.out.println("list数据为："+list);
		Map<String,Object> result = new HashMap<String,Object>();
		//list.isEmpty() 里面没有数据
		if(list == null || list.isEmpty()) {
			result.put("code", "600");
			result.put("msg", "暂无数据....");
			return result;
		}
		result.put("code", 0);
		result.put("data", list);
		result.put("count", typeInfoMapper.getTotal());
		return result;
	}
}
